package info.nixbear.tgcms.domain;

import javax.jdo.annotations.Discriminator;
import javax.jdo.annotations.DiscriminatorStrategy;
import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.Version;
import javax.jdo.annotations.VersionStrategy;

import com.google.appengine.api.datastore.Text;

@PersistenceCapable(identityType=IdentityType.APPLICATION, detachable="true")
@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME)
@Version( 
		strategy=VersionStrategy.VERSION_NUMBER, 
		column = "version", 
		extensions={@Extension(vendorName="datanucleus", key="field-name", 
		value="version")}) 
public class Template extends EntityBase {

	@Persistent private String name;

    @Persistent private String contentType;
    
    @Persistent private Text html;
    
	@Persistent private Long parentTemplateId;
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getContentType() {
		return contentType;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	public Text getHtml() {
		return html;
	}

	public void setHtml(Text html) {
		this.html = html;
	}

	public Long getParentTemplateId() {
		return parentTemplateId;
	}

	public void setParentTemplateId(Long parentTemplateId) {
		this.parentTemplateId = parentTemplateId;
	}

	public String getHtmlAsString() {
		return (this.getHtml()==null)?null:this.getHtml().getValue();
	}
	
	public void setHtmlAsString(String htmlString) {
		this.setHtml(new Text(htmlString));
	}

}
